#import "sprite_game_object.h"

#import "mgr_game_physics.h"

@implementation SpriteGameObject

@synthesize objectName = objectName_;

- (id)initSpriteGameObject
{
	if ((self = [super init]))
	{
		objectName_ = "object base";
		
		/*box2d
		*/
		box2dBody_ = NULL;
		
		/*flag
		*/
		flagItemTimeStopValid_ = true;
		
		/*set up update box2d tick
		*/
		[self schedule:@selector(tickUpdateBox2d:)];
	}
	return self;
}

- (void)dealloc
{
	[self destroyBody];
	[super dealloc];
}

- (void)tickUpdateBox2d:(ccTime)Time
{
	if (NULL != box2dBody_)
	{
		box2dBody_->SetTransform([self ComputeBodyPosition], 0.0f);
	}
}

- (void)createBody
{
	b2BodyDef bodyDef;
	
	bodyDef.type = b2_dynamicBody;
	box2dBody_ = CMgrGamePhysics::World()->CreateBody(&_BodyDef);
}

- (void)destroyBouy
{
	if (NULL != box2dBody_)
	{
		CMgrGamePhysics::World()->destroyBody(box2dBody_);
		box2dBody_ = NULL;
	}
}

- (b2Vec2)computeBodyPosition
{
	b2Vec2 point;
	
	point.Set(self.positionInPixels.x, self.positionInPixels.y);
	point = ptScaleVector_same(_Point, 1 / CMgrGamePhysics::Ratio());
	return point;
}

- (void)pause
{
}

- (void)resume
{
}

- (void)itemFunctionTimeStop
{
}

- (void)itemFunctionTimeStopOver
{
}

- (void)damage:(float)DamagePoint
{
	return false;
}

- (bool)isInvsible
{
	return false;
}

@end